package com.freshfresh.adapter;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.freshfresh.activity.R;
import com.freshfresh.view.BannerPager;


public class IndexViewPager
  
{
  private Activity ac;
  private List<String> imgUrls;
  private List<Map<String,Object>> urlBeans;

  private void setUrlBeans(List<Map<String,Object>> paramList)
  {
    this.urlBeans = paramList;
    if (paramList == null);
    while (true)
    {
      this.imgUrls = new ArrayList();
      Iterator localIterator = paramList.iterator();
      while (localIterator.hasNext())
      {
    	  Map<String,Object> localIndexViewPagerDataListItem = (Map<String,Object>)localIterator.next();
        this.imgUrls.add(localIndexViewPagerDataListItem.get("banner_url").toString());
      }
    }
  }

  public View getView(Activity paramActivity, List<Map<String,Object>> paramList)
  {
    this.ac = paramActivity;
    setUrlBeans(paramList);
    LayoutInflater localLayoutInflater = LayoutInflater.from(paramActivity);
    View localView1 = localLayoutInflater.inflate(R.layout.index_list_item1, null);
    BannerPager localBannerPager = (BannerPager)localView1.findViewById(R.id.bp_index);
    if ((this.imgUrls == null) || (this.imgUrls.size() == 0))
      return localView1;
    ArrayList localArrayList = new ArrayList();
    for (int i = 0; ; i++)
    {
      if (i >= this.imgUrls.size())
      {
        localBannerPager.setVisibility(0);
        localBannerPager.setCanScroll(true);
        LinearLayout localLinearLayout = (LinearLayout)localView1.findViewById(R.id.ll_index_dot);
        BannerAdapter localBannerAdapter = new BannerAdapter(localArrayList, this.imgUrls, paramActivity);
        localBannerPager.setAdapter(localBannerAdapter);
        localBannerPager.setCurrentItem(20 * localArrayList.size());
        localBannerPager.setOvalLayout(paramActivity, localLinearLayout, this.imgUrls.size(), 2130837598);
        localBannerPager.startScroll(paramActivity);
//        localBannerAdapter.setOnCustomListener(this);
        return localView1;
      }
      View localView2 = localLayoutInflater.inflate(R.layout.ac_guide_item, null);
      localView2.setTag("");
      localArrayList.add(localView2);
    }
  }

//  public void onCustomerListener(View paramView, int paramInt)
//  {
//    IndexViewPagerDataListItem localIndexViewPagerDataListItem = (IndexViewPagerDataListItem)this.urlBeans.get(paramInt);
//    Intent localIntent = new Intent(this.ac, ProductDetailsActivity.class);
//    localIntent.putExtra("productid", localIndexViewPagerDataListItem.getProductid());
//    localIntent.putExtra("categoryid", localIndexViewPagerDataListItem.getCategories());
//    this.ac.startActivity(localIntent);
//  }
}